package com.weirong.smartvault.backservice.entity_model;

import com.weirong.smartvault.common.tools.spring.context.SpringContextUtil;
import com.weirong.smartvault.dao.ForeignCurrencyTypeRepository;
import com.weirong.smartvault.entity.ForeignCurrencyType;
import com.weirong.smartvault.entity.StockHistory;

import java.util.Date;

/**
 * 于2017/12/19由 KFEB4 创建 .
 */
public class StockHistoryModel {
    StockHistory stockHistory;
    ForeignCurrencyTypeRepository foreignCurrencyTypeRepository;

    public StockHistoryModel(StockHistory stockHistory) {
        this.stockHistory = stockHistory;
        foreignCurrencyTypeRepository = SpringContextUtil.getBean(ForeignCurrencyTypeRepository.class);
    }

    public String getCurrencyName() {
        //获取币种名称
        String typeCode = getTypeCode();
        ForeignCurrencyType foreignCurrencyType = foreignCurrencyTypeRepository.getByCode(typeCode);
        return foreignCurrencyType.getName();
    }

    public Integer getSum(){
        return getDenominationValue()*getAmount();
    }

    public Integer getDenominationValue() {
        return this.stockHistory.getDenominationValue();
    }

    public Integer getAmount() {
        return stockHistory.getAmount();
    }

    public String getTypeCode() {
        return stockHistory.getTypeCode();
    }

    public Date getModifyTime(){
        return stockHistory.getModifyTime();
    }
}
